<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 5，随机点名程序
	提示：把人名都放进数组，随机产生一个下标，根据下标取出一个人名 -->
    <!-- <input type="button" value="点名" onclick="fn()"> -->
    <script>
        function randomName(arr) {
            // 随机产生一个下标
              n=parseInt(Math.random()*arr.length)
              return arr[n]

         }
            var names=['嘉琪',"心怡","文件"]
      console.log(randomName(names));
        

    </script>
</body>

</html>